<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="primus" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" tagdir="/WEB-INF/tags/form" %>
<primus:page title="申请售后">
    <jsp:attribute name="css">
        <style type="text/css">
            #table .operate {
                min-width: 80px;
            }
        </style>
    </jsp:attribute>
    <jsp:attribute name="script">
        <script type="application/javascript">
            $(function () {
                $("#table").DataTable({
                    "lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "所有"]],
                    "columnDefs": [{"targets": [7], "orderable": false}],
                    "searching": false,
                    "order": [[0, "asc"]]
                });
            });
            $("body").on("click", ".geo-line", function () {
                var id = $(this).data("id");
            })
        </script>
    </jsp:attribute>
    <jsp:body>
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="welcome.do">
                        首页
                    </a>
                </li>
                <li>
                    <a href="geo/provinces">
                        订单管理
                    </a>
                </li>
                <li class="active">
                    申请售后列表
                </li>
            </ul>
        </div>

        <div class="page-content">

            <!-- 模态框 -->
            <div class="modal fade" style="width: 100%; height: 100%;" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content" style="width: 100%; height: 100%; display: inline-table;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h3>拒绝售后</h3>
                        </div>
                        <br>
                        <div class="row">
                            <label class="col-sm-2 control-label no-padding-right">拒绝原因</label>
                            <div class="col-sm-8">
                                <select id="orderSele">
                                    <option value="self_now">sss</option>
                                    <option value="self_normal">已cccc审核</option>
                                </select>
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <label class="col-sm-2 control-label no-padding-right">拒绝备注</label>
                            <div class="col-sm-8">
                                <textarea rows="3" cols="65" style="resize: none;" class="con_inf_address myRemark" id="refuseSuccessTex"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-success" id="refuseSuccessButton">
                            同意
                        </button>
                        <button class="btn btn-primary" data-dismiss="modal">
                            取消
                        </button>
                    </div>
                </div>
            </div>

            <!-- 模态框 -->
            <div class="modal fade" style="width: 100%; height: 100%;" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content" style="width: 100%; height: 100%; display: inline-table;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h3>同意售后</h3>
                        </div>
                        <br>
                        <div class="row">
                            <label class="col-sm-2 control-label no-padding-right">同意备注</label>
                            <div class="col-sm-8">
                                <textarea rows="3" cols="65" style="resize: none;" class="con_inf_address myRemark" id="consentSuccessTex"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-success" id="consentSuccessButton">
                            同意
                        </button>
                        <button class="btn btn-primary" data-dismiss="modal">
                            取消
                        </button>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <div class="row">
                        <div class="col-xs-12">
                            <h3 class="header smaller lighter blue">
                                售后审核
                            </h3>
                            <div class="row">
                                <div class="tabbable" style="float:right">
                                    <button class="btn btn-white btn-default btn-round" id="closeButton">
                                        <i class="ace-icon fa fa-times red2" style="padding:0;margin:0;float:left;box-sizing:border-box;"></i>
                                        关闭
                                    </button>
                                </div>
                                <div class="tabbable" style="width: 100%; height: 100%; display: inline-table;">

                                    <div id="ord_bas_inf" class="tab-pane">
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >订单来源</label>
                                                <input type="text" class="col-xs-8 col-sm-8 orderSourceInpu" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >订单编号</label>
                                                <input type="text" class="col-xs-8 col-sm-8 orderCodeInpu" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >售后类型</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >申请金额</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >是否原路返回</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >原订单总金额</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >优惠券</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >促销活动</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >会员电话</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >原单支付方式</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >会员姓名</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >申请理由</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="row">
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >申请备注</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                            <div class="col-sm-5">
                                                <label class="col-sm-4 control-label no-padding-right" >申请时间</label>
                                                <input type="text" class="col-xs-8 col-sm-8" />
                                            </div>
                                        </div>
                                        <br>
                                        <br>
                                        <hr>
                                        <div class="row">
                                            <h4>售后商品</h4>
                                            <table id="table_act_inf" class="table table-hover" style="width: 100%;">
                                                <thead>
                                                <tr>
                                                    <th>商品编码</th>
                                                    <th>商品名称</th>
                                                    <th>商品数量</th>
                                                    <th>商品金额</th>
                                                </tr>
                                                </thead>
                                            </table>
                                        </div>
                                        <hr>
                                        <br>
                                        <br>
                                        <div class="row" style="text-align:center">
                                            <div style="margin: 0 auto">
                                                <button class="btn btn-primary" id="refuseButton">
                                                    拒绝申请
                                                </button>
                                                <button class="btn btn-primary" id="agreeButton">
                                                    同意申请
                                                </button>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>

        <script>
            $(function(){

                GetRequest(sessionStorage.getItem('aftermarketApplicationsCode'));     // 初始化
            });

            // 关闭按钮(跳转回派单列表页面)
            $("#closeButton").on("click", function () {
                window.location.href="/aftermarketApplications.do";
            });

            // 获取session 存储的值
            function GetRequest(vc) {
                $.ajax({
                    url:"aftermarketApplications/auditReturnDetail",
                    dataType: "json",
                    data: {
                        "returnCode": vc
                    },
                    success: function (result) {
                        if (result != null) {
//                            aft_sal_inf();    // 售后信息赋值

                            $("#table_act_inf").dataTable({     //售后商品列表初始化
                                searching: false,
                                ordering: false,
                                paging: false, // 禁止分页
                                data:result.omsReturnItemVos
                            });
                        }
                    }
                });
            }

            // 拒绝申请按钮
            $("#refuseButton").on("click", function () {
                $("#myModal1").modal({show:true});
            });

            // 拒绝申请按钮
            $("#agreeButton").on("click", function () {
                $("#myModal2").modal({show:true});
            });

            //验证(详细地址)
            $(".myRemark").on("blur", function(){
                if ($(".myRemark").val().length > 200) {
                    layer.msg("'备注'长度不可超过200");
                    $(".myRemark").val("");
                }
            });

            // 拒绝申请按钮
            $("#refuseSuccessButton").on("click", function () {
                $.ajax({
                    url:"aftermarketApplications/auditReturn",
                    dataType: "json",
                    type: "POST",
                    data: {
                        "auditState": "reject",
                        "returnCode": sessionStorage.getItem('aftermarketApplicationsCode'),
                        "remark": $("#refuseSuccessTex").val()
                    },
                    success: function (result) {
                        window.location.href="/aftermarketApplications.do";   //跳转列表页面
                    }
                });
            });

            // 同意申请按钮
            $("#consentSuccessButton").on("click", function () {
                $.ajax({
                    url:"aftermarketApplications/auditReturn",
                    dataType: "json",
                    type: "POST",
                    data: {
                        "auditState": "pass",
                        "returnCode": sessionStorage.getItem('aftermarketApplicationsCode'),
                        "remark": $("#consentSuccessTex").val()
                    },
                    success: function (result) {
                        window.location.href="/aftermarketApplications.do";   //跳转列表页面
                    }
                });
            });

            // 售后信息赋值
            function aft_sal_inf(data) {
                $(".orderSourceInpu").val(data.orderSource) //订单来源
                $(".orderCodeInpu").val(data.orderCode)     //订单编号
            }
        </script>
    </jsp:body>
</primus:page>